<script>
	/**
	* Resizes the content div
	*/
	function SetContentWidth(element)
	{
		contentElement = document.getElementById('frame_file_source').contentDocument.getElementById('editor');
		contextMenuElement = document.getElementById('context_menu');

		if (element.className == "")
		{
			contentElement.style.width = parseInt(contentElement.style.width) + parseInt(contextMenuElement.style.width) + 'px';
		}
		else
		{
			contentElement.style.width = parseInt(contentElement.style.width) - parseInt(contextMenuElement.style.width) + 'px';
		}
	}
</script>

<?php
	$topMenu = array
	(
		'file' => array
		(
			'text' => ucfirst(LANG_FILE),
			'url' => '#',
			'sub' => array
			(
				'save' => array
				(
					'text' => ucfirst(LANG_SAVE),
					'url' => '#',
					'attributes' => 'onClick = "document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'save\').click(); return false"', 
				),
				'model' => array
				(
					'text' => ucfirst(LANG_MODEL),
					'url' => '/spanel/viewsource/index/model/'.$this->data[name],
				),
				'controller' => array
				(
					'text' => ucfirst(LANG_CONTROLLER),
					'url' => '/spanel/viewsource/index/controller/'.$this->data[name],
				),
				'views' => array
				(
					'text' => ucfirst(LANG_VIEWS),
					'url' => '#',
				),
			)
		),
		'window' => array
		(
			'text' => ucfirst(LANG_WINDOW),
			'url' => '#',
			'sub' => array
			(
				'refresh' => array
				(
					'text' => ucfirst(LANG_REFRESH),
					'url' => '#',
					'attributes' => 'onclick = "RefreshSession(); return false;"', 
				),
				'0' => array
				(
					'text' => ucfirst(LANG_TOPBAR),
					'url' => '#',
					'attributes' => 'id = "toggle_topbar" onClick = "SwitchSelectedOption(this);"',
					'class' => 'selectedOption'
				),
				'1' => array
				(
					'text' => ucfirst(LANG_CONTEXT_MENU),
					'url' => '#',
					'attributes' => 'id = "toggle_context_menu" onClick = "SwitchSelectedOption(this); SetContentWidth(this); "',
					'class' => 'selectedOption'
				),
				'2' => array
				(
					'text' => ucfirst(LANG_CONTENT),
					'url' => '#',
					'attributes' => 'id = "toggle_page_content" onClick = "SwitchSelectedOption(this);"',
					'class' => 'selectedOption'
				),
			)
		),
		'editor' => array
		(
			'text' => ucfirst(LANG_EDITOR),
			'url' => '#',
			'sub' => array
			(
				'toolbars' => array
				(
					'text' => ucfirst(LANG_TOOLBARS),
					'url' => '#',
					'sub' => array
					(					
						'0' => array
						(
							'text' => ucfirst(LANG_APP_HELPERS),
							'url' => '#',
							'attributes' => 'onClick = "ShowHideObject(document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'application_helpers\')); SwitchSelectedOption(this);"',
							'class' => 'selectedOption'
						),
						'1' => array
						(
							'text' => ucfirst(LANG_SF_HELPERS),
							'url' => '#',
							'attributes' => 'onClick = "ShowHideObject(document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'framework_helpers\')); SwitchSelectedOption(this);"',
							'class' => 'selectedOption'
						),
						'2' => array
						(
							'text' => ucfirst(LANG_CORE_FUNCTIONS),
							'url' => '#',
							'attributes' => 'onClick = "ShowHideObject(document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'core\')); SwitchSelectedOption(this);"',
							'class' => 'selectedOption'
						),
					),
				),
				'charmap_but' => array
				(
					'text' => ucfirst(LANG_VISUAL_KEYBOARD),
					'url' => '#',
					'attributes' => 'onClick = "document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'charmap_but\').click(); return false"', 
				),
				'go_to_line' => array
				(
					'text' => ucfirst(LANG_GO_TO_LINE),
					'url' => '#',
					'attributes' => 'onClick = "document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'go_to_line\').click(); return false"', 
				),
				'search' => array
				(
					'text' => ucfirst(LANG_SEARCH),
					'url' => '#',
					'attributes' => 'onClick = "document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'search\').click(); return false"', 
				),
				'undo' => array
				(
					'text' => ucfirst(LANG_UNDO),
					'url' => '#',
					'attributes' => 'onmouseover = "if (document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'undo\').className == \'editAreaButtonDisabled\') {this.className = \'NOROLL\';} else {this.className = \'\';};" onClick = "document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'undo\').click(); return false"', 
				),
				'redo' => array
				(
					'text' => ucfirst(LANG_REDO),
					'url' => '#',
					'attributes' => 'onmouseover = "if (document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'redo\').className == \'editAreaButtonDisabled\') this.className = \'NOROLL\'; else this.className = \'\';" onClick = "document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'redo\').click(); return false"', 
				),
				'about' => array
				(
					'text' => ucfirst(LANG_ABOUT),
					'url' => '#',
					'attributes' => 'onClick = "document.getElementById(\'frame_file_source\').contentDocument.getElementById(\'help\').click(); return false"', 
				)
			)
		),
		'help' => array
		(
			'text' => ucfirst(LANG_HELP),
			'url' => '#',
			'attributes' => "onclick = 'window.open(\"/spanel/main/help/\",\"_blank\",\"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no,width=800,height=600,screenX=150,screenY=150,top=150,left=150\")'"
		),
		'logout' => array
		(
			'text' => ucfirst(LANG_LOGOUT),
			'url' => '/spanel/main/logout/',
		)
		
	);
	
	//hide editor menu for the pages without the editor
	if ($this->name != 'ViewSource')
	{
		unset($topMenu[editor]);
		unset($topMenu[file]);
	}
	else
	{
		if ((is_dir("././app/views/{$this->data[name]}/"))&&(!empty($this->data[name])))
		{
			foreach ($this->GetFileNames("././app/views/{$this->data[name]}/") as $view)
			{
				$view_button[text] = $view;
				$view_button[url] = "/spanel/viewsource/index/view/{$this->data[name]}/$view";
				$topMenu[file][sub][views][sub][] = $view_button;
			}					
		}
	}
	
	//slider map elements
	$sliderElements = array
	(
		'topbar' => array ('type' => 'vertical', 'columns' => '2', 'title' => LANG_PAGE_HEADER, 'new_line' => true, 'html_attributes' => 'style = "text-align: center; border: 1px solid grey"'),
		//'context_menu' => array ('type' => 'horizontal', 'columns' => '1', 'title' => LANG_CONTEXT_MENU, 'new_line' => true, 'html_attributes' => 'style = "text-align: center; border: 1px solid grey"'),
		'page_content' => array ('type' => 'horizontal', 'columns' => '1', 'title' => LANG_PAGE_CONTENT, 'new_line' => false, 'html_attributes' => 'style = "text-align: center; border: 1px solid grey"'),
	);
	Mootools::SliderMap($sliderElements, "cellpadding = '0' cellspacing = '0' id = 'slideBox' style = 'display: none; position: absolute; top: 0px; left: 250px; width: 250px; border: 1px black solid; border-collapse: collapse;'");	
	
	echo "<a href = '#' id = 'slidein_context_menu' style = 'display: none'></a>";
	Mootools::HorizontalSlide('context_menu', '', true, true);
	
	//creates horizontal menu
	HorizontalMenu::CreateMenu($topMenu);	
?>

<div id  = "topmenu"></div>